package section3.Begin;

import java.io.*;
import java.util.Scanner;

//根据附件的文件<水浒传.txt>
//输入一个名字，查找他在梁山的封号
public class Title {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        FileInputStream ifle = null;
        BufferedReader bf = null;
        String a = null;
        try {
            InputStreamReader in = new InputStreamReader(new FileInputStream("D:\\Y2\\java\\作业\\java高级特性\\水浒传.txt"), "GBK");
            bf = new BufferedReader(in);
            System.out.println("请输入名字");
            String s = input.next();
            while ((a = bf.readLine()) != null) {
                if (a.indexOf(s) > 0) {
                    System.out.println(a.substring(1, 11));//substring() 方法返回字符串的子字符串。重0开始
                }
            }

        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }

    }
}